<?php


namespace app\model\pay;


use App\Common\Lib\Platform;
use app\model\BaseModel;

class ApplePayNotifyLogModel extends BaseModel
{
    protected $table = 'video_applepay_notify_log';

    protected $primaryKey = 'id';

    public $timestamps = false;

    protected static $instance;

    public static function getInstance()
    {
        //        if(is_object(self::$instance)){
//            return self::$instance;
//        }

        return new self();
    }

    public function insertData($param)
    {
        $insert = [
            'notify_content' => $param['notify_content']??'',
            'signedpayload' => isset($param['signedpayload']) ? json_encode($param['signedpayload'],256) : '[]',
            'data' => isset($param['data']) ? json_encode($param['data'],256) : '[]',
            'notification_type' => isset($param['notificationType'])? json_encode($param['notificationType'], true) : '',
            'notification_uuid' => $param['notificationUUID']??'',
            'subtype' => $param['subtype']??'',
            'transaction_info' => isset($param['transactionInfo'])? json_encode($param['transactionInfo'], true):'[]',
            'renewal_info' => isset($param['renewalInfo']) ?json_encode($param['renewalInfo'], true):'[]',
            'is_renew' => $param['is_renew']??'-1',
            'result' => $param['result']??'0',
        ];

        return $this->insertGetId($insert);
    }
}
